/**
 *
 */
package com.wedroid.r2d2.dao;

import com.demo2do.core.persistence.annotation.Dynamic;
import com.demo2do.core.persistence.annotation.Query;
import com.demo2do.core.persistence.annotation.Save;
import com.demo2do.core.persistence.annotation.Update;
import com.demo2do.core.persistence.annotation.Variable;
import com.wedroid.entity.contact.Droid;

/**
 * @author lute
 */
@Dynamic
public interface DroidDao {

    /**
     * @param name
     * @return
     */
    @Query("SELECT id AS id, name AS name, nick_name AS 'profile.nick_name', remark_name AS 'profile.remark_name', display_name AS 'profile.display_name', head_img_url AS 'profile.head_img_url', contact_flag AS 'profile.contact_flag', member_count AS 'profile.member_count', alias AS 'profile.alias', sex AS 'profile.sex', province AS 'profile.province', city AS 'profile.city', signature AS 'profile.signature' FROM droid WHERE name = :name")
    public Droid getDroidByName(@Variable("name") String name);

    /**
     * @param droid
     */
    @Save("INSERT INTO droid (name, nick_name, remark_name, display_name, head_img_url, contact_flag, member_count, alias, sex, province, city, signature) VALUES (:name, :profile.nickName, :profile.remarkName, :profile.displayName, :profile.headImgUrl, :profile.contactFlag, :profile.memberCount, :profile.alias, :profile.sex, :profile.province, :profile.city, :profile.signature)")
    public void createDroid(Droid droid);

    /**
     * @param droid
     */
    @Update("UPDATE droid set remark_name = :profile.remarkName, display_name = :profile.displayName, head_img_url = :profile.headImgUrl, contact_flag = :profile.contactFlag, member_count = :profile.memberCount, alias = :profile.alias, sex = :profile.sex, province = :profile.province, city = :profile.city, signature = :profile.signature")
    public void updateDroidProfile(Droid droid);

}
